﻿using System;
using Jayden.Dll.Web.HtmlControls.Descriptions;
using Jayden.Dll.Web.HtmlControls.Generics;
using Jayden.Dll.Web.HtmlControls.Interfaces;
using System.Collections.Generic;

namespace Jayden.Dll.Web.HtmlControls
{
	public class A : HtmlElement, WithHRef, WithTarget, WithType
	{
		public A() : base(ADescription.Instance) { }
		public A(string text, string href = null, bool htmlEncode = true)
			: this()
		{
			if (text != null)
				AddText(text, htmlEncode);
			if (href != null)
				this["href"] = href;
		}

		public string HRef { get { return this["href"]; } set { this["href"] = value; } }
		public string Target { get { return this["target"]; } set { this["target"] = value; } }
		public string Type { get { return this["type"]; } set { this["type"] = value; } }
		public string Rel { get { return this["rel"]; } set { this["rel"] = value; } }
		public string HRefLang { get { return this["hreflang"]; } set { this["hreflang"] = value; } }
		public string Media { get { return this["media"]; } set { this["media"] = value; } }
	}
	public class ADescription : HtmlElementDescription
	{
		public static readonly ADescription Instance = new ADescription();
		private ADescription() : base("a") { }
		public override Type ControlType { get { return typeof(A); } }
		public override bool IsPhrasingElement { get { return true; } }
		public override string Description { get { return "hyperlink"; } }

		public override IEnumerable<string> PermittedAttributes
		{
			get
			{
				yield return "href";
				yield return "target";
				yield return "rel";
				yield return "hreflang";
				yield return "media";
				yield return "type";
			}
		}
	}

}
